# Gendered targeting: Do parties tailor their campaign ads to women?

## Overview
This repository contains the data and code necessary to replicate the analyses in "Gendered targeting: Do parties tailor their campaign ads to women?" by Cornelius Erfort. 

## Software Requirements
- R in macOS Sequioa 15.2 (packages listed in `scripts/packages.R`)
- Stata 17.0 in Windows 11

## File Structure

### Data Files (`/data`)
- `ads_imgs_vids.RData`: R data file containing advertisement, image, and video data
- `ads_imgs_vids.dta`: Stata version of the advertisement dataset
- `snapchat_ads.RData`: Data related to Snapchat advertisements
- `view_party.csv`: Party-related data from ParlGov
- `info_id.csv`: Additional information for ParlGov data

### Code Files (`/scripts`)
- `figures-and-tables.Rmd`: R Markdown file generating figures and tables
- `main-models-stata.do`: Main Stata analysis script
- `packages.R`: R package dependencies

### Output Files

#### Plots (`/plots`)
- `figure1b_example_ad_audience_composition.pdf`: Figure 1b: Example ad with data from the Facebook Ad Library: Demographic audience composition
- `figure2_marginsplot.pdf`: Figure 2: Predicted probabilities for the tailoring to women
- `figure_a1_gender_ratio.pdf`: Figure A.1: Distribution of gender ratio of ad target groups
- `figure_a2_tailoring_targeting_party_family.pdf`: Figure A.2: Tailoring and targeting by party
- `figure_c4_women_ads_party_family.pdf`: Figure C.4: Women on ad images by party family
- `figure_h6_keyness_ES_UP.png`: Figure H.6: Keywords and keyness scores for ads targeted at women, Spain, Unidas Podemos (ParlGov ID: 2724)
- `figure_h7_keyness_ES_C-PC.png`: Figure H.7: Keywords and keyness scores for ads targeted at women, Spain, C-PC (ParlGov ID: 2375)
- `figure_h8_keyness_DE_B90-Gru.png`: Figure H.8: Keywords and keyness scores for ads targeted at women, Germany, B90/Gru (ParlGov ID: 772)
- `figure_h9_keyness_GB_Lib.png`: Figure H.9: Keywords and keyness scores for ads targeted at women, United Kingdom, Lib (ParlGov ID: 659)
- `figure_i10_women_ads_party_family.pdf`: Figure I.10: Women on ad images by party family
- `figure_i11_marginsplot_family.pdf`: Figure I.11: Predicted probabilities for the tailoring to women

#### Tables (`/tables`)
- `table_a1_tailoring_targeting.tex`: Table A.1: List of parties
- `table_a2_summary_statistics.tex`: Table A.2: Summary statistics for all variables

#### Stata Output (`/stata-output`)
- Numbered output files (1-5) in .tex, .txt, and .xls formats 
1. Table D.3: Results from logistic regression (main models)
2. Table E.4: Results from logistic regression: Only images, excluding videos
3. Table E.5: Results from logistic regression: Different IV, Continuous share of women among
audience
4. Table E.6: Results from logistic regression: Different DV, only women on image
5. Table E.7: Results from logistic regression: No controls
- Age-related regression outputs (age.tex, age.txt, age.xls): Table G.9: Results from OLS regression, images only
- Margins data files:
  - `Christian_democracy.dta`
  - `Communist_Socialist.dta`
  - `Conservative.dta`
  - `Green_Ecologist.dta`
  - `Liberal.dta`
  - `Social_democracy.dta`
  - `margins.dta`
- Plots:
  - `figure_g5_marginsplot_age.pdf`: Figure G.5: Predicted probabilities for the tailoring by age

## Instructions for Replication
1. Ensure all required software is installed
2. Run the Stata analysis using `scripts/main-models-stata.do`
3. Install R packages using `scripts/packages.R`
4. Generate figures and tables by knitting `scripts/figures-and-tables.Rmd`

## Log Files 
- `figures-and-tables.pdf`
- `main-models-stata.log`

## Data and Code Availability Statement
All data and code necessary for replication are included in this repository. The analysis can be fully reproduced using the provided scripts and data files.

## Contact
Cornelius Erfort
www.corneliuserfort.de